package com.example.demo.controller.rmqp;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author 高俊
 * @create 2021-08-2021/8/13-17:09
 */
public class RmqpConnection {

    public static final String NEW_QUENE = "new_quene";
    public static Channel getConnection() throws Exception{
        // 创建连接工厂
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("47.119.120.116");
        connectionFactory.setUsername("guest");
        connectionFactory.setPassword("guest");

        // 创建连接
        Connection connection = connectionFactory.newConnection();
        // 创建信道
        Channel channel = connection.createChannel();
        return channel;
    }
}
